# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=munin-hashchecker
_pkgname=munin
pkgver=242.95ac249
pkgrel=1
pkgdesc='Online hash checker for Virustotal and other services'
groups=('blackarch' 'blackarch-defensive' 'blackarch-forensic')
arch=('any')
url='https://github.com/Neo23x0/munin'
license=('Apache')
depends=('python' 'python-colorama' 'python-future' 'python-requests'
         'python-pymisp' 'python-flask' 'python-flask-caching'
         'python-cfscrape' 'python-pycurl' 'python-dnspython' 'python-ipy')
makedepends=('git')
source=("git+https://github.com/Neo23x0/$_pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $_pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$_pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $_pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$_pkgname"

  cat > "$pkgdir/usr/bin/$_pkgname-host" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $_pkgname-host.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$_pkgname-host"
}

